package com.yq.ylmall.product.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yq.ylmall.dto.product.CategoryBrandNameQueryDto;
import com.yq.ylmall.model.product.CategoryBrand;
import com.yq.ylmall.product.mapper.CategoryBrandMapper;
import com.yq.ylmall.product.service.ICategoryBrandService;
import com.yq.ylmall.vo.product.BrandVo;
import com.yq.ylmall.vo.product.CategoryBrandPageVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 分类品牌 服务实现类
 * </p>
 *
 * @author yzk789
 * @since 2024-05-31
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class CategoryBrandServiceImpl extends ServiceImpl<CategoryBrandMapper, CategoryBrand> implements ICategoryBrandService {
    private final CategoryBrandMapper categoryBrandMapper;

    @Override
    public IPage<CategoryBrandPageVo> queryCategoryBrand(CategoryBrandNameQueryDto dto) {
        IPage<CategoryBrandPageVo> page = new Page<>(dto.getPageNum(), dto.getPageSize());
        return baseMapper.queryCategoryBrand(page, dto);
    }

    @Override
    public boolean doUpdate(CategoryBrand dto) {
        categoryBrandMapper.updateByIds(dto);
        return true;
    }

    @Override
    public List<BrandVo> getBrandByCategoryId(Long categoryId) {
        return categoryBrandMapper.getBrandByCategoryId(categoryId);
    }

    @Override
    public List<Long> getParentCategoryIds(Long categoryId) {
        return categoryBrandMapper.getParentCategoryIds(categoryId);
    }


}
